ActionController::Routing::Routes.draw do |map|
  map.resources :pages

  # Sample of named route:
  #   map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
  # This route can be invoked with purchase_url(:id => product.id)

  # Define Root page:
  map.connect '', 
              :category => 'index',
              :page => 'index',
              :controller => 'public', 
              :action => 'showpage'
 
  map.connect ':category/:page.html', 
              :controller => 'public', 
              :action => 'showpage'
              
              
  # Setup Named Routes:

  map.index  'index.html',
              :category => 'index',
              :page => 'index',
              :controller => 'public', 
              :action => 'showpage'
              
  map.image '/uploadimage.form',
               :controller => 'pages', :action => 'uploadimage'
  
  
  map.about '/about.html', 
              :category => 'index', :page => 'about',
              :controller => 'public', :action => 'showpage'
              
  map.delivery '/delivery.html', 
              :category => 'index', :page => 'delivery',
              :controller => 'public', :action => 'showpage'
              
  map.map     '/map.html', 
              :category => 'index', :page => 'map',
              :controller => 'public', :action => 'showpage'
  
  map.map     '/special-offers.html', 
              :category => 'index', :page => 'special-offers',
              :controller => 'public', :action => 'showpage'
  
  map.map     '/clearance-items.html', 
              :category => 'index', :page => 'clearance-items',
              :controller => 'public', :action => 'showpage'
  
              
  # Routes for the edit pages:
  map.edit   'showpages.edit',
              :controller => 'pages',
              :action => 'showlist'
              
  map.newcat  'newcategory.edit',
              :controller => 'pages',
              :action => 'newcat'
              
  map.newpage 'newpage.edit',
              :controller => 'pages',
              :action => 'newpage'
  
  map.logout  'logout',
              :controller => 'users',
              :action => 'logout'
              
  # Setup the image page:

  #map.resources :pages do |page|
  #     page.resources :images
  #     page.resource :bigimage
  #end
  
  map.resources :pages, :has_many => :images
  map.resources :pages, :has_many => :bigimages
  map.resources :pages, :has_many => :textimages
  
  map.resources :sidebox
  map.resources :images
  map.resources :bigimages
  map.resources :textimages
  
  # Install the default routes as the lowest priority.
  map.connect ':controller/:action'
  map.connect ':controller/:action/:id'
  map.connect ':controller/:action/:id.:format'
end
